package cn.wolfcode.wolf2w.util;

import lombok.Getter;
import lombok.Setter;

@Getter
public enum RedisKeys {

    //表示验证码的key,通过前缀维护唯一性,使用time维护有效时间
    VERIFY_CODE("verify_code",Consts.VERIFY_CODE_VAI_TIME*60L),
    //表示用户登录的令牌
    LOGIN_TOKEN("login_token",Consts.USER_INFO_TOKEN_VAI_TIME*60L),

    STRATEGY_USER_THUM("strategy_user_thum", -1L),

    USER_FAVOR("user_favor", -1L),

    STRATEGY_STATIC_VO("strategy_statis_vo",-1L);

    //前缀属性
    @Setter
    private String prefix;
    //有效时间
    @Setter
    private Long time;
    //创建一个有参构造器
    private RedisKeys(String prefix, Long time) {
        this.prefix = prefix;
        this.time = time;
    }
    //设置验证码key的拼接格式
        public  String join(String... values){
        StringBuilder sb = new StringBuilder(50);
        sb.append(this.prefix);
            for (String value : values) {
                sb.append(":").append(value);
            }
        return sb.toString();
    }
}
